package com.haoshuang.zhouzhoubang.ui.vm

import com.haoshuang.zhouzhoubang.model.api.ApiRepo
import com.haoshuang.zhouzhoubang.model.bean.ExtraCostsPayBean
import com.mufeng.libs.base.BaseViewModel
import com.mufeng.libs.net.netRequest
import com.mufeng.libs.state.StateData
import com.mufeng.libs.state.StatefulMutableLiveData
import kotlinx.coroutines.flow.MutableStateFlow

class ExtraCostsPayViewModel : BaseViewModel() {

    /**
     * 获取支付二维码
     */
    val makeCostScanPayOrderData = StatefulMutableLiveData<ExtraCostsPayBean>()
    fun makeCostScanPayOrder(orderId: String) = netRequest {
        start { makeCostScanPayOrderData.value = StateData.Loading }
        request { ApiRepo.makeCostScanPayOrder(orderId) }
        success { makeCostScanPayOrderData.value = StateData.Success(it.data) }
        error { code, msg ->
            makeCostScanPayOrderData.value = StateData.Error(code, msg)
        }
    }
}